package com.xsmart.goods.api.wx;

import com.xsmart.common.entity.RequestBean;
import com.xsmart.common.entity.ResponseBean;
import com.xsmart.goods.services.wx.WxGoodsCategoryService;
import com.xsmart.goods.services.wx.WxGoodsService;
import com.xsmart.goods.services.wx.WxGoodsShopService;
import com.xsmart.goods.services.wx.WxIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.Response;

/**
 * 微信接口
 * @author guojd
 */
@RestController
@RequestMapping("/api")
public class WxGoodsController {
    /**
     * 首页推荐信息
     */
    @Autowired
    WxIndexService wxIndexService;
    /**
     * 商品分类
     */
    @Autowired
    WxGoodsCategoryService wxGoodsCategoryService;
    /**
     * 商品信息
     */
    @Autowired
    WxGoodsService wxGoodsService;

    /**
     * 店铺商品
     */
    @Autowired
    WxGoodsShopService wxGoodsShopService;

    /**
     * 首页推荐信息
     * @param requestBean 查询对象
     * @param request 请求对象
     * @return 推荐内容
     */
    @PostMapping(value = "/v1/IndexService/queryIndexData")
    public ResponseBean queryIndexData(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return wxIndexService.queryIndexData(requestBean);
    }

    /**
     * 查询推荐对象
     * @param requestBean
     * @param request
     * @return
     */
    @PostMapping(value = "/v1/IndexService/queryPriority")
    public ResponseBean queryPriority(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return wxIndexService.queryPriority(requestBean);
    }

    /**
     * 分类推荐
     * @param requestBean
     * @param request
     * @return
     */
    @PostMapping(value = "/v1/IndexService/queryCategoryPriority")
    public ResponseBean queryCategoryPriority(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return wxIndexService.queryCategoryPriority(requestBean);
    }



    /**
     * 首页推荐商品列表
     * @param requestBean 查询对象
     * @param request 请求对象
     * @return 推荐商品列表
     */
   @PostMapping(value = "/v1/IndexService/queryIndexProList")
    public ResponseBean queryIndexProList(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return wxIndexService.queryIndexProList(requestBean);
    }

    /**
     * 查询商品分类父级分类，同时返回第一个父级分类下的子分类
     * @param requestBean 查询对象
     * @param request 请求对象
     * @return 父级分类、子分类
     */
    @PostMapping(value = "/v1/WxGoodsController/queryGoodsCategoryRoot")
    public ResponseBean queryGoodsCategoryRoot(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return wxGoodsCategoryService.queryGoodsCategoryRoot(requestBean);
    }

    /**
     * 根据父级分类查询子分类
     * @param requestBean 查询对象
     *                    cat_id 分类id
     * @param request 请求对象
     * @return 子分类
     */
    @PostMapping(value = "/v1/WxGoodsController/queryGoodsCategory")
    public ResponseBean queryGoodsCategory(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return wxGoodsCategoryService.queryGoodsCategory(requestBean);
    }

    /**
     * 商品详情
     * @param requestBean 请求对象
     *                    goods_id 商品id
     * @param request 请求对象
     * @return 商品详情
     */
    @PostMapping(value = "/v1/WxGoodsController/queryGoodsDetail")
    public ResponseBean queryGoodsDetail(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return wxGoodsService.queryGoods(requestBean);
    }

    /**
     * 获取商品的顾客评价
     * @param requestBean
     * @param request
     * @return
     */
    @PostMapping(value = "/v1/WxGoodsController/queryCustomerAppraise")
    public ResponseBean queryCustomerAppraise(@ModelAttribute RequestBean requestBean,HttpServletRequest request){
        return wxGoodsService.queryCustomerAppraise(requestBean);
    }

    /**
     * 新增商品评价
     * @param requestBean
     * @param request
     * @return
     */
    @PostMapping(value="/v1/WxGoodsController/addGoodsAppraise")
    public ResponseBean addGoodsAppraise(@ModelAttribute RequestBean requestBean,HttpServletRequest request){
        return wxGoodsService.addGoodsAppraise(requestBean);
    }

    /**
     * 获取相似推荐的商品
     * @param requestBean
     * @param request
     * @return
     */
    @PostMapping(value="/v1/WxGoodsController/queryRecommend")
    public ResponseBean queryRecommend(@ModelAttribute RequestBean requestBean,HttpServletRequest request){
        return wxGoodsService.queryRecommend(requestBean);
    }

    /**
     * 商品列表
     * @param requestBean 请求对象
     *                    cat_id:分类id,
     *                    ptype:ptype,
     *                    brand_id: 品牌id
     * @param request 请求对象
     * @return 商品详情
     */
    @PostMapping(value = "/v1/WxGoodsController/queryGoodsList")
    public ResponseBean queryGoodsList(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return wxGoodsService.queryGoodsList(requestBean);
    }

    /**
     * 分销商店铺商品分类列表
     * @param requestBean
     * @param request
     * @return
     */
    @PostMapping(value = "/v1/WxGoodsController/queryGoodsShopList")
    public ResponseBean queryGoodsShopList(@ModelAttribute RequestBean requestBean, HttpServletRequest request){
        return wxGoodsShopService.queryShopCategoryList(requestBean);
    }

    /**
     * 查询分销商店铺商品列表
     * @param requestBean
     * @param request
     * @return
     */
    @PostMapping(value = "/v1/WxGoodsController/queryShopGoodsList")
    public ResponseBean queryShopGoodsList(@ModelAttribute RequestBean requestBean, HttpServletRequest request){
        return wxGoodsShopService.queryShopGoodsList(requestBean);
    }

    /**
     * 查询搜索结果
     * @param requestBean
     * @param request
     * @return
     */
    @PostMapping(value = "/v1/WxGoodsController/querySearchList")
    public ResponseBean querySearchList(@ModelAttribute RequestBean requestBean,HttpServletRequest request){
        return wxGoodsService.querySearchList(requestBean);
    }

    /**
     * 查询搜索记录
     * @param requestBean
     * @param request
     * @return
     */
    @PostMapping(value = "/v1/WxGoodsController/querySearchHis")
    public ResponseBean querySearchHis(@ModelAttribute RequestBean requestBean,HttpServletRequest request){
        return wxGoodsService.querySearchHis(requestBean);
    }
}
